/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ca.ubc.icapture.genapha.forms;

import icapture.beans.DB.Gene;
import icapture.beans.KeggPathwayBean;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.Resources;
import org.apache.struts.validator.ValidatorForm;

/**
 *
 * @author BTripp
 */
public class PathwayForm extends ValidatorForm {
    
    private String URL;
    private Collection<Gene> geneList;
    private String pathwayName;
    private KeggPathwayBean keggPathwayBean;
    private String pathwayID;
    
    //Used to submit form
    private String submitType;
    private String[] geneNames;

    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
    {
        ActionErrors errors = super.validate(mapping, request);
        if (getSubmitType() != null)
        // GOTCHA: There is no snp ratio test in Investigator's.
        {
            if (getGeneNames() == null || getGeneNames().length <= 0)
            {
                errors.add("genes",
                        new ActionMessage("errors.required", Resources.getMessage(request, "pathway.gene")));
            }
        }
        return errors;
    }
    
    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        setSubmitType(null);
        setGeneNames(null);
    }

    /**
     * @return the URL
     */
    public String getURL()
    {
        return URL;
    }

    /**
     * @param URL the URL to set
     */
    public void setURL(String URL)
    {
        this.URL = URL;
    }

    /**
     * @return the geneList
     */
    public Collection<Gene> getGeneList()
    {
        return geneList;
    }

    /**
     * @param geneList the geneList to set
     */
    public void setGeneList(Collection<Gene> geneList)
    {
        this.geneList = geneList;
    }

    /**
     * @return the pathwayName
     */
    public String getPathwayName()
    {
        return pathwayName;
    }

    /**
     * @param pathwayName the pathwayName to set
     */
    public void setPathwayName(String pathwayName)
    {
        this.pathwayName = pathwayName;
    }

    /**
     * @return the keggPathwayBean
     */
    public KeggPathwayBean getKeggPathwayBean()
    {
        return keggPathwayBean;
    }

    /**
     * @param keggPathwayBean the keggPathwayBean to set
     */
    public void setKeggPathwayBean(KeggPathwayBean keggPathwayBean)
    {
        this.keggPathwayBean = keggPathwayBean;
    }

    /**
     * @return the pathwayID
     */
    public String getPathwayID()
    {
        return pathwayID;
    }

    /**
     * @param pathwayID the pathwayID to set
     */
    public void setPathwayID(String pathwayID)
    {
        this.pathwayID = pathwayID;
    }

    /**
     * @return the submitType
     */
    public String getSubmitType()
    {
        return submitType;
    }

    /**
     * @param submitType the submitType to set
     */
    public void setSubmitType(String submitType)
    {
        this.submitType = submitType;
    }

    /**
     * @return the geneNames
     */
    public String[] getGeneNames()
    {
        return geneNames;
    }

    /**
     * @param geneNames the geneNames to set
     */
    public void setGeneNames(String[] geneNames)
    {
        this.geneNames = geneNames;
    }
}